package  com.loma.service;
import  com.loma.entity.Project;
import  com.loma.dao.ProjectDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class ProjectService {
@Autowired
private ProjectDao dao;

    public    Project  save(Project json){
        return dao.save(json);

    }

    public     Project   findById(Project json){
        return dao.findById(json.getId()).get()  ;

    }

    public    void  delete( Project json){
          dao.delete(json);

    }
    public Page<Project> list( Project json, int page){
       ExampleMatcher matcher=  ExampleMatcher.matching();
        matcher.withIgnoreNullValues(); 
      return   dao.findAll(Example.of(json), PageRequest.of(page,10));  
        
    }} 
